

// 培训或考试进度条形
function trainProcess_bar(container,title,legendText,data,sum) {

    var myChart = echarts.init(document.getElementById(container));
    var option = {
        title : {
            text: title,
            x:'center',
            y:'bottom'
        },
        tooltip : {
            trigger: 'axis'
        },
        color:['#ffac32','#2db7fb','#4df0f0','#f3e24f'],
        toolbox: {
            show : true,
        },
        legend: {
            data:[title]
        },
        calculable : true,
        xAxis : [
            {
                type : 'category',
                width : '15%',
                data : legendText
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        series : [
            {
                name:'',
                type:'bar',
                data: data,
                /*data: [10,
                      20,
                       30,
                       40],*/
                itemStyle: {

                    normal: {
                        barBorderRadius :[8,8,0,0]  ,
                        color: function(params) {
                            // build a color map as your need.
                            var colorList = [
                                '#5B9BD5','#5B9BD5', '#5B9BD5'
                            ];
                            return colorList[params.dataIndex]
                        },
                        label: {
                            show: true,
                            position: 'top',
                            formatter: '{b}\n{c}'
                        }
                    }
                },
                barWidth:40
            }
        ]
    };

    myChart.setOption(option);


}

// 培训或考试进度对比图
function trainProcess_pie(container,title,legendText,data,sum) {
    var legend_0 = legendText[0] + " : " + data[0] + "%";
    var legend_1 = legendText[1] + " : " + data[1] + "%";
    var legend_2 = legendText[2] + " : " + data[2] + "%";
    var myChart = echarts.init(document.getElementById(container));
    option = {
        title : {
            text: title,
            x:'center',
            y:'bottom'
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b}"
        },
        color:['#A5A5A5','#ED7D31','#5B9BD5'],
        legend: {
            orient : 'vertical',
            x : 'right',
            data:legendText
        },
        toolbox: {
            show : false,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                magicType : {
                    show: true,
                    type: ['pie', 'funnel'],
                    option: {
                        funnel: {
                            x: '25%',
                            width: '50%',
                            funnelAlign: 'left',
                            max: 1548
                        }
                    }
                },
                restore : {show: true},
                saveAsImage : {show: false}
            }
        },
        calculable : true,
        series : [
            {
                name:'培训进度',
                type:'pie',
                radius : '50%',
                center: ['45%', '50%'],
                itemStyle : {
                    normal : {
                        label : {
                            show : true
                        },
                        labelLine : {
                            show : true
                        }
                    }
                },
                label: {
                    normal: {
                        show: true,
                        formatter: '{b}({d}%)'
                    }
                },
                data:[
                    {value:data[0], name:legendText[0]},
                    {value:data[1], name:legendText[1]},
                    {value:data[2], name:legendText[2]}
                ]
            }
        ]
    };


    myChart.setOption(option)

}
